package com.iespring.controller.admin.promotion;

import com.fasterxml.jackson.databind.ser.Serializers;
import com.iespring.bean.admin.promotion.bo.MallTopicBo;
import com.iespring.bean.admin.promotion.po.MallTopic;
import com.iespring.bean.admin.promotion.vo.MallTopicVo;
import com.iespring.bean.common.BasePageInfo;
import com.iespring.bean.common.BaseRespVo;
import com.iespring.bean.common.CommonData;
import com.iespring.service.poromotion.PromotionTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author:ZhangShuPeng
 * @Date:2022/12/29/20:45
 * @Description:
 */
@RestController
@RequestMapping("admin/topic")
public class TopicController {

    @Autowired
    PromotionTopicService promotionTopicService;

    @RequestMapping("list")
    public BaseRespVo list(BasePageInfo info, String title, String subTitle) {

        CommonData<MallTopic> data = promotionTopicService.list(info, title, subTitle);
        BaseRespVo baseRespVo = BaseRespVo.ok(data);

        return baseRespVo;
    }

    @RequestMapping("create")
    public BaseRespVo create(@RequestBody MallTopicBo mallTopicBo) {

        MallTopicVo mallTopicVo = promotionTopicService.create(mallTopicBo);
        BaseRespVo baseRespVo = BaseRespVo.ok(mallTopicVo);

        return baseRespVo;
    }

    @RequestMapping("read")
    public BaseRespVo read(@RequestBody MallTopic mallTopic) {

        MallTopic mallTopic1 = promotionTopicService.read(mallTopic);
        BaseRespVo baseRespVo = BaseRespVo.ok(mallTopic1);

        return baseRespVo;
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody MallTopic mallTopic) {

        int rows = promotionTopicService.delete(mallTopic);
        BaseRespVo baseRespVo = BaseRespVo.ok(rows);

        return baseRespVo;
    }

    @RequestMapping("batch-delete")
    public BaseRespVo batchDelete(Integer[] integers) {

        int rows = promotionTopicService.batchDelete(integers);
        BaseRespVo baseRespVo = BaseRespVo.ok(rows);

        return baseRespVo;
    }
}
